package com.xmcowell.sportpacemaster.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.xmcowell.sportpacemaster.base.MyApplication;

/**
 * 图片加载工具
 * Created by xmsz on 2016/11/18.
 */

public class ImageLoader {

    public static void load(final Context context, String imageUrl, ImageView imageView) {
        Glide.with(context).load(imageUrl).asBitmap().into(imageView);
//        Glide.with(context.getApplicationContext()).load(imageUrl).asBitmap().placeholder(R.drawable.ic_picture_loading)
//                .error(R.drawable.ic_picture_loadfailed).into(imageView);
    }

    public static void load(final Context context, int imageUrl, ImageView imageView) {
        Glide.with(context).load(imageUrl).into(imageView);
    }

    public static void load(String imageUrl, ImageView imageView) {
        Glide.with(MyApplication.getInstatnce()).load(imageUrl).into(imageView);
    }

    public static void load(int imageUrl, ImageView imageView) {
        Glide.with(MyApplication.getInstatnce()).load(imageUrl).into(imageView);
    }


    public static void load_big(Context context, String imageUrl, ImageView imageView) {
        Glide.with(context)
                .load(imageUrl)
                .skipMemoryCache(true)
                .into(imageView);
    }

    /**
     * 加载圆形头像
     *
     * @param context
     * @param imageUrl
     * @param imageView
     */
    public static void load_head(Context context, String imageUrl, ImageView imageView) {
        Glide.with(context)
                .load(imageUrl)
                .transform(new CircleImageTransformation(context))
                .into(imageView);
    }

}
